Skip to content

Comments

feat: implement & test open_at#363

Open
Sl1mb0 wants to merge 20 commits intomainfrom
tm/open-at
Open

feat: implement & test open_at#363
Sl1mb0 wants to merge 20 commits intomainfrom
tm/open-at

Conversation

@Sl1mb0
Copy link
Contributor

@Sl1mb0 Sl1mb0 commented Feb 9, 2026

Closes #336

I followed the specification described here. Given that we will eventually need to test this against the wasi test-suite, any differences between the aforementioned spec and the test-suite will favor the test-suite; so significant changes may need to be made in the future.

Describe your proposed changes here.

  • I've read the contributing section of the project CONTRIBUTING.md.
  • Signed CLA (if not already signed).

@Sl1mb0 Sl1mb0 force-pushed the tm/open-at branch 12 times, most recently from a5a3acf to 967f281 Compare February 10, 2026 02:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements POSIX/WASI-like open_at behavior in the in-memory VFS so guests can open existing nodes and create/truncate files (a prerequisite for enabling host-side FS writes), and updates unit/integration tests to reflect the new semantics.

Changes:

  • Refactors VFS path resolution and expands VfsCtxView::open_at to handle CREATE, EXCLUSIVE, DIRECTORY, and TRUNCATE.
  • Adds extensive unit tests around open_at behavior and updates integration test expectations/snapshots.
  • Makes Limiter::grow take &self (internally synchronized), simplifying ownership/mutability in component setup.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
host/src/vfs/mod.rs Implements new open_at semantics, factors path traversal helper, and adds unit tests.
host/src/limiter.rs Changes grow to &self to allow shared use behind a mutex.
host/src/component.rs Adjusts limiter initialization to match the new Limiter::grow signature/usage.
host/tests/integration_tests/python/runtime/fs.rs Updates Python FS integration test to exercise create-on-open behavior.
host/tests/integration_tests/evil/fs.rs Updates large snapshot expectations for new VFS/open behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Sl1mb0 Sl1mb0 force-pushed the tm/open-at branch 9 times, most recently from d7bd5c4 to adb81f9 Compare February 10, 2026 04:57
let limiter = Limiter::new(self.static_limits, &pool);
let vfs_state = VfsState::new(limits, limiter);
let table = ResourceTable::new();
(table, vfs_state)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We return a non-mutable tuple here instead of the VfsCtxView directly, as wrapping these in the VfsCtxView requires that they be mutable references, and rustc doesn't like that 😞

@Sl1mb0 Sl1mb0 force-pushed the tm/open-at branch 3 times, most recently from 6278d31 to 9d61c8c Compare February 17, 2026 15:42
| | . | ERR: Is a directory (os error 31) |
| | .. | ERR: Is a directory (os error 31) |
| | / | ERR: Is a directory (os error 31) |
| | /bin | ERR: Bad file descriptor (os error 8) |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this result in "invalid" or "not found" or something? "Bad file descriptor" kinda sound like an internal mess-up.

Copy link
Contributor Author

@Sl1mb0 Sl1mb0 Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's really only two places we return BadDescriptor. I'm still trying to nail down why exactly this is happening.

Copy link
Contributor Author

@Sl1mb0 Sl1mb0 Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we're hitting this, so the resource we're trying to get doesn't exist in the resource table.

This kind of makes sense though doesn't it? if none of the source/destinations exist; since we start with a new VFS for each test.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guest code however doesn't create Resource<Descriptor> out of thin air (I think, at least if it's not buggy). So we must have handed out a descriptor that is broken or something? Or do we have some kind of type confusion or broken cast at some point?

Copy link
Contributor Author

@Sl1mb0 Sl1mb0 Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a broken cast? I have no idea what could be the cause. I think if something is going wrong it's related to get_directories - as that's where the resource is initially created and added the ResourceTable. Setting breakpoints here and here, and then running test_copy, we first push a descriptor on to the table, and then when we get it we get BadDescriptor - which is only returned if the the descriptor isn't found in the resource table - so something is not quite adding up.

What's strange is examining the ResourceTable when hitting the BadDescriptor breakpoint shows that it contains an entry; and that entry points to the same value as what's added to it in get_directories.

Reading more about std::fs::copy(from, to), there is this tidbit regarding an error case:

from is neither a regular file nor a symlink to a regular file.

To me this reads that if the file it does try to copy is a directory, it will fail since a directory is neither of those things. And since ., .., and / all exist on the VFS but are directories. If I run this test locally, I do encounter the .. neither a regular file nor a symlink .. error. So that also points to this being the cause of the error.

As for what we should do about this - maybe just remove those values specifically from PATHS? I don't really see that as ideal either, as we definitely want to test those.

I wonder if maybe we should break up the evil tests by files that we expect to be in the VFS vs. files we don't expect to be there?

EG, we could have another constant EXISTING_VFS_PATHS that consists of that list (., .., /) and combine it with PATHS for most tests, but then break it up for certain tests like test_copy. Just kind of a spitball idea ATM though.

@Sl1mb0 Sl1mb0 force-pushed the tm/open-at branch 3 times, most recently from 862b2a5 to 259bdb4 Compare February 18, 2026 22:30
@Sl1mb0 Sl1mb0 force-pushed the tm/open-at branch 7 times, most recently from 71e926e to c750feb Compare February 19, 2026 15:42
@Sl1mb0 Sl1mb0 requested a review from crepererum February 20, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor HostDescriptor::open_at for VfsCtxView to allow writes

3 participants